home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
pxcreate
/
pxcreate.frm
< prev
next >
Wrap
Text File
|
1995-09-06
|
6KB
|
142 lines
VERSION 2.00
Begin Form Form1
Caption = "PX Create"
ClientHeight = 1170
ClientLeft = 870
ClientTop = 1530
ClientWidth = 2820
Height = 1575
Left = 810
LinkMode = 1 'Source
LinkTopic = "Form1"
ScaleHeight = 1170
ScaleWidth = 2820
Top = 1185
Width = 2940
Begin TextBox ResLabel
BackColor = &H00FFFFFF&
BorderStyle = 0 'None
Height = 252
Left = 120
TabIndex = 2
Text = "PXTblCreate Result"
Top = 840
Width = 1812
End
Begin TextBox ReturnCode
Height = 372
Left = 2040
TabIndex = 1
Top = 720
Width = 612
End
Begin CommandButton Command1
Caption = "Generate Test File"
Height = 492
Left = 120
TabIndex = 0
Top = 120
Width = 2532
End
End
'**************************************************************************
' This code is provided "AS IS" into the public domain.
'
' I needed to use The paradox engine with VB and this is my solution to
' the problem of creating a table with the paradox engine and VB. I put
' this together very quickly and did not have much time testing. There may
' be BUGS in this code that I have not found!
' It is your responsibility to determine if it is suitible for your purposes.
'
' Jim Nech
' OutRider Systems (Producers of Custom Controls for Visual Basic)
'
' Voice: 713-521-0486 Fax: 713-523-0386
'**************************************************************************
' SEE: The programmers reference for Paradox for windows for
' complete descriptions of all Paradox functions available.
'
' The following two functions are needed anytime you use the Paradox engine
' for windows.
Declare Function PXWinInit Lib "pxengwin.dll" (ByVal AppName$, ByVal PxShare%) As Integer
Declare Function PXExit Lib "pxengwin.dll" () As Integer
' This is the Paradox engine function that creates a data file. Two of it's
' arguments are pointers to arrays of pointers to strings. Since VB doesn't
' provide for arrays of pointers to strings we will have to improvise. See
' the next declare statement.
Declare Function PXTblCreate Lib "pxengwin.dll" (ByVal lpName$, ByVal NumFields%, Flds As Any, Types As Any) As Integer
' This is a standard windows API call. We use it because it returns the far
' address of it's string argument.
' We are going to lie to VB and tell VB that it is returning a long. The
' reason for this is that we need to store this value in one of the elements
' of an array of longs. A long is the same size as a far address. We are then
' going to pass the PXTblCreate function a pointer to an array of longs
' instead of a pointer to an array of pointers to strings. If the elements
' of the array of longs are actually addresses of strings then it's address
' is actually a pointer to an array of pointers to strings.
Declare Function AnsiUpper Lib "user" (ByVal lpString$) As Long
' The following arrays will hold the pointers to strings. To see how they are
' used see the code attached to the Command1 button.
Dim PxFields(5) As Long
Dim PxTypes(5) As Long
'***************************************************************************
' This code is provided "AS IS" into the public domain.
'
' I needed to use The paradox engine with VB and this is my solution to
' the problem of creating a table with the paradox engine and VB. I put
' this together very quickly and did not have much time testing. There may
' be BUGS in this code that I have not found!
' It is your responsibility to determine if it is suitible for your purposes.
'
' Jim Nech
' OutRider Systems (Producers of Custom Controls for Visual Basic)
'
' Voice: 713-521-0486 Fax: 713-523-0386
'***************************************************************************
'
' See the declarations for this module for more detailed information on
' The various DLL calls and their arguments.
Sub Command1_Click ()
FLD0$ = "Numeric Field" ' First field name
FLD1$ = "Alpha Field" ' Second field name
FLD2$ = "Date Field" ' Ditto
FLD3$ = "Currency Field" ' Ditto
FLD4$ = "Short Field" ' Ditto
' Assign the addresses of the strings that define the field names
' to the elements of the fields array.
PxFields(0) = AnsiUpper(FLD0$)
PxFields(1) = AnsiUpper(FLD1$)
PxFields(2) = AnsiUpper(FLD2$)
PxFields(3) = AnsiUpper(FLD3$)
PxFields(4) = AnsiUpper(FLD4$)
TYP0$ = "N" ' First field type
TYP1$ = "A50" ' Second field type
TYP2$ = "D" ' Ditto
TYP3$ = "$"
TYP4$ = "S"
' Assign the addresses of the strings that define the field types to
' the elements of the Types array.
PxTypes(0) = AnsiUpper(TYP0$)
PxTypes(1) = AnsiUpper(TYP1$)
PxTypes(2) = AnsiUpper(TYP2$)
PxTypes(3) = AnsiUpper(TYP3$)
PxTypes(4) = AnsiUpper(TYP4$)
TableName$ = "table" ' This is the name of the table to create
x = PXWinInit("TESTSTR", 0) ' Initialize paradox for windows
' Make the call to create the table
x = PXTblCreate(TableName$, 5, PxFields(0), PxTypes(0))
x = PXExit() ' Exit paradox for windows
ReturnCode.Text = Str$(x) ' Save the return code and display it
End Sub